<?php
class Attribute extends Vnf_Db_Table{
    protected $_name;
    protected $_primary = 'AttributeID';

    function __construct() {
        $this->_name = DB_PREFIX . "attribute";
        parent::__construct(); 
    }

    public function getColumns() {
        $results = array('AttributeID', 'ProductNo', 'SKU', 'Attribute1', 'Attribute2', 'Attribute3', 'Attribute4', 'Attribute5', 'Attribute6', 'Attribute7', 'Attribute8', 'Attribute9', 'Attribute10', 'Price', 'Cost', 'Quantity', 'Unit', 'Weight', 'Length', 'Height', 'Width', 'ContainerCode', 'BillingInterval', 'SubscriptionPeriod', 'IntervalBegin', 'NewBillType', 'StartupFee', 'RenewUpdateInd', 'Isbn', 'Mpn', 'Upc', 'Condition');
        return $results;
    }

    public function getPrimaryKey() {
        $pk = $this->_primary;
        if (is_array($pk)) {
            if (count($pk) > 0)
                return $pk[1]; // array[1] contain column name of primary key
        }
        return $this->_primary;
    }
    
    public function getRecords($where = null, $order = null, $count = null, $offset = 0) {
        $table_name = $this->_name;
        $primary_key = $this->getPrimaryKey();
        $select = $select = Zend_Db_Table_Abstract::select();
        $select->setIntegrityCheck(false)
            ->from(array('thistable' => $table_name))
            ->joinLeft( array( 'f0table' => DB_PREFIX . "product"), "thistable.ProductNo = f0table.ProductNo", array('Product'));
        if($where) {
            $select->where($where);
        }
        if($order) {
            $select->order($order);
        }
        if($count)
            $select->limit($count, $offset);
        $data = $this->fetchAll($select);
        return $data;
    }}
?>
